<template>
    <div class="my-header">
        <!-- 搜索 -->
        <div class="search-btn" data-url="category" @click="jump"></div>
        <div class="search">
            <div class="jd-icon"></div>
            <div class="circle"></div>
        </div>
        <div class="login" data-url="login" @click="jump">登录</div>
    </div>
</template>

<script>
export default {
    name: "MyHeader",
    methods:{
        jump(e){
            // console.log(e.currentTarget.dataset.url)
            let { url } = e.currentTarget.dataset;
            console.log(url);
            this.$router.push({name:url})
            // this.$store.dispatch("bar/handleSrc", src, { root: true });
        }
    }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
.my-header {
    position: relative;
    overflow: hidden;
    background-color: #c93a26;
    height: 44px;
    .search-btn {
        position: absolute;
        top: 0;
        left: 0;
        width: 40px;
        height: 44px;
        &::before {
            content: "";
            display: block;
            width: 20px;
            height: 18px;
            background: url("~@/assets/img/s-btn.png") no-repeat;
            background-size: 20px 18px;
            margin: 14px 0 0 15px;
        }
    }
    .search {
        height: 30px;
        margin-top: 7px;
        margin-left: 50px;
        margin-right: 50px;
        margin-bottom: 7px;
        border-radius: 15px;
        background-color: #fff;
        position: relative;
        .jd-icon {
            position: absolute;
            top: 8px;
            left: 13px;
            width: 20px;
            height: 15px;
            background: url("~@/assets/img/jd.png") no-repeat;
            background-size: 20px 15px;
            &::after {
                content: "";
                display: block;
                width: 1px;
                height: 15px;
                position: absolute;
                top: 0px;
                right: -8px;
                background-color: #ccc;
            }
        }
        .circle {
            position: absolute;
            top: 8px;
            left: 46px;
            width: 18px;
            height: 15px;
            background: url("~@/assets/img/jd-sprites.png") no-repeat -81px 0;
            background-size: 200px auto;
        }
    }
    .login {
        position: absolute;
        top: 0;
        right: 0;
        width: 40px;
        height: 44px;
        line-height: 44px;
        color: #fff;
    }
}
.my-header-fixed {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
}
</style>
